package gae.testjig.client.eventbus;

import gae.testjig.client.ClientChannelId;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.HandlerRegistration;

public class TestStatusEvent extends GwtEvent<TestStatusEvent.Handler> {

	public interface Handler extends EventHandler {
		public void onEvent(TestStatusEvent event);
	}
	
	static private Type<Handler> TYPE = new Type<Handler>();
	static public HandlerRegistration registerToSource(EventBus bus, ClientChannelId source, Handler handler) {
		return bus.addHandlerToSource(TYPE, source, handler);
	}
	
	private int invocations;
	private int retries;
	private int mismatches;
	
	public TestStatusEvent(int invocations, int retries, int mismatches) {
		this.invocations = invocations;
		this.retries = retries;
		this.mismatches = mismatches;
	}

	@Override
	protected void dispatch(Handler handler) {
		handler.onEvent(this);
	}

	@Override
	public Type<Handler> getAssociatedType() {
		return TYPE;
	}

	public int getInvocations() {
		return invocations;
	}
	public int getRetries() {
		return retries;
	}
	public int getMismatches() {
		return mismatches;
	}

}
